﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheOutLetLibrary.Dominio;
using System.Data.OleDb;

namespace TheOutLetLibrary.Infraestrutura {

    public class Accessk_cartDAO : BaseDAO, IGenericDAO<k_cart> {

        public Accessk_cartDAO(OleDbTransaction transacao)
            : base(transacao) {
        }

        public int Inclua(k_cart entity) {

            OleDbCommand comando = GetCommand();

            comando.CommandText = 
                " INSERT INTO k_cart (" +
                " NR_PEDIDO, totalDiscountAmount, totalInterestAmount, totalAmount) " +
                " VALUES (" +
                " @NR_PEDIDO, @totalDiscountAmount, @totalInterestAmount, @totalAmount)";
            comando.Parameters.Add("@NR_PEDIDO", OleDbType.Integer).Value = entity.NR_PEDIDO;
            comando.Parameters.Add("@totalDiscountAmount", OleDbType.VarChar).Value = entity.totalDiscountAmount.ToString();
            comando.Parameters.Add("@totalInterestAmount", OleDbType.VarChar).Value = entity.totalInterestAmount.ToString();
            comando.Parameters.Add("@totalAmount", OleDbType.VarChar).Value = entity.totalAmount.ToString();
            comando.ExecuteNonQuery();

            comando.CommandText = "SELECT @@IDENTITY";
            entity.COD = Convert.ToInt32(comando.ExecuteScalar());
            return entity.COD;

        }

        public k_cart Ache(int Id) {
            throw new NotImplementedException();
        }
    }
}
